home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-4543 / mvg / mod_code / meth2.s < prev    next >
Text File  |  1987-04-21  |  17KB  |  629 lines

  1. ; Equates file for   Module METHOD # 2
  2. ; FUNCTION CALLS  from MVG v1.3 only!
  3.  
  4. ; output gridbig.prg
  5.  
  6.  
  7. ***************************************************************************
  8. *                                      *
  9. * ------------------------ First, some legalese ------------------------- *
  10. *                                      *
  11. * Source code Copyright (C) 1989,90 W. David Parks. All rights reserved.  *
  12. * No part of this SOURCE CODE may be reproduced, transmitted, transcribed *
  13. * stored in a retrieval system, or translated in any form or by any means *
  14. * without the prior written permission of the author, W.D.Parks          *
  15. *                                      *
  16. *                                      *
  17. * We make no representations or warranties with respect to the contents   *
  18. * of this document and specifically disclaim any implied warranties or    *
  19. * merchantability, or fitness for any particular purpose.                 *
  20. *                                      *
  21. * ----------------------------------------------------------------------- *
  22. *                                      *
  23. *    Written permission is granted to registered owners to use         *
  24. *       any or all of this source code in their own modules for           *
  25. *    private use. Please contact Dr. Bobware for details for           *
  26. *    any commercial use.                          *
  27. *                                      *
  28. *                                      *
  29. *                                      *
  30. ***************************************************************************
  31.  
  32. * last changed: 04/19/90
  33.  
  34.  
  35. * this source code is intended for HiSoft's Assembler, GENST2.
  36. * other assemblers can be used with little modification.
  37. * the biggest requirement is it's MACRO capability.
  38. * after having Macros, I find it quite hard to live without them.
  39. * although I'm sure I remember a time when I did... 
  40. * or was that just a nightmare I once had... I dunno...
  41.  
  42. ;source code is copyright w.david parks, all rights reserved
  43. ;
  44. ;
  45. ;MOD_EQU: Standard equates for Module setup
  46.  
  47. *****************************************************************************
  48. **************************  MACROS for EASY Functions ***********************
  49. *****************************************************************************
  50.  
  51.  
  52. ******************************* Call a routine that's inside MVG.
  53. ******************************* Use inline.
  54. ******************************* sample: callmvg ANYKEY
  55. callmvg macro function_number
  56.  push.l #\1
  57.  move.l mvg_func,a6
  58.  jsr (a6)
  59.  addq.l #4,sp
  60.  endm
  61.  
  62. ******************************* Call a routine that's inside MVG.
  63. ******************************* Use for stand-alone routine in MODULE
  64. ******************************* (places an RTS at the end... that's all)
  65. callmvgr macro function_number
  66.  callmvg \1
  67.  rts
  68.  endm
  69.  
  70.  
  71. ******************************* Lazy_Typer's MOVE.? _whatever_,-(sp)
  72. ******************************* 
  73. ******************************* ie  Push something on the stack
  74. ******************************* 
  75. ******************************* HISOFT option "\0" automatically
  76. ******************************* appends any entered size, default=W
  77. ******************************* sample:  PUSH.L #4   = move.l #4,-(sp)
  78. push macro
  79.  move.\0 \1,-(sp)
  80.  endm
  81.  
  82. ******************************* Lazy_Typer's MOVE.? (sp)+,_whatever_
  83. ******************************* 
  84. ******************************* ie  Pop something off the stack
  85. ******************************* 
  86. ******************************* HISOFT option "\0" automatically
  87. ******************************* appends any entered size, default=W
  88. ******************************* sample:  POP.L D7   = move.l (sp)+,D7
  89. pop macro
  90.  move.\0 (sp)+,\1
  91.  endm
  92.  
  93. ******************************* Lazy_Typer's MOVEM.L A0-A6/D0-D7,-(sp)
  94. ******************************* 
  95. ******************************* ie  push everything on the stack!
  96. pha macro
  97.  movem.l a0-a6/d0-d7,-(sp)
  98.  endm
  99.  
  100. ******************************* Lazy_Typer's MOVEM.L (sp)+,A0-A6/D0-D7
  101. ******************************* 
  102. ******************************* ie  pop everything back off the stack!
  103. pla macro
  104.  movem.l (sp)+,a0-a6/d0-d7
  105.  endm
  106.  
  107.  
  108.  
  109.  
  110. ;--------------------------------------------------------------------
  111. ;                     MVG Packet #2 equates
  112. ;--------------------------------------------------------------------
  113. ;
  114. ;equates used as Function Number for calling MVG via "callmvg"
  115. ;
  116.  
  117. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  118. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  119. ;
  120. ;  REMEMBER! MVG 1.2 owners CANNOT use this method of packet access
  121. ;
  122. ;    !!!!!!!!!!SO BE SURE TO CHECK THE VERSION NUMBER!!!!!!!!!
  123. ;
  124. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  125. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  126.  
  127.  
  128.  
  129. GETVARS    equ 0    ;A1--> Varlist
  130. GETBUFS    equ 1    ;A0->Main, D0=W,H  D1=MAXLEN, A1->CB
  131. GETCBUF    equ 2    ;A0->CB
  132. C_VID2CB   equ 3    ;COPY video to CB
  133. C_VID2MAIN equ 4    ;copy video to main (0-3)
  134. C_CB2MAIN  equ 5    ;copy CB to main (0-3)
  135. C_MAIN2CB  equ 6    ;copy main (0-3) to CB
  136. ANYKEY     equ 8    ;wait for key, returnds D0.L
  137. WHEREM     equ 9
  138. SETXY      equ 10
  139. GDISPLAY   equ 11
  140. DISPLAY_CB equ 12
  141. TOPTITLE   equ 13
  142. HI_CHAR    equ 14
  143. HI_STRING  equ 15
  144. PHEX1      equ 16
  145. HEXIT      equ 17
  146. HEXITL     equ 18
  147. BDEC2      equ 19
  148. BDEC3      equ 20
  149. BDEC4      equ 21
  150. GET_MISC   equ 22
  151. ASKMISC    equ 23
  152. COPYTOZ    equ 26
  153. APPENDTO   equ 27
  154. ADDEXT     equ 28
  155. SETMOUSEXY equ 31
  156. SETSIZE    equ 35
  157. ATOG_NRM   equ 36
  158. ATOG_XOR   equ 37
  159. MAKEBOX    equ 38
  160. MAKEXBOX   equ 39
  161. SET_LINE   equ 40
  162. MAKELINE   equ 41
  163. RECTANG_Q  equ 42
  164. EALERT     equ 45
  165.  
  166. ;-------------------------  equates for index into VAR_LIST
  167. V_WID equ 0
  168. V_HGT equ 4
  169. V_PIX equ 8
  170. V_REZ equ 12
  171. V_CBF equ 24
  172. V_INTI equ 32
  173. V_ADRI equ 36
  174. V_INTO equ 40
  175. V_ADRO equ 44
  176. V_MDIR equ 48
  177. V_MFIL equ 52
  178. V_FILN equ 56
  179. V_RFIL equ 60
  180.  
  181.  
  182.  
  183.  
  184. *******************************************************************
  185. ;=================================================================
  186. ;       MOD_INI: Initialization routines for Module setup
  187. ;=================================================================
  188. ;
  189. ; the program proper
  190. ;
  191. ;
  192.  
  193.  section text
  194.  
  195.  
  196.  
  197. PRG_INIT:
  198.  bra begin
  199.  
  200. siggy
  201.  dc.b 'MVG Module: xxxxxx xxxxxx xxx',0     ;30 bytes
  202.  even
  203.  
  204.  
  205.  
  206. begin
  207.  
  208.     move.l    4(a7),a3        base page
  209.     move.l  a3,basepage        save it for later
  210.     move.l    #ustack,a7        use local stack
  211.     move.l    $c(a3),d0        text len
  212.     add.l    $14(a3),d0        data len
  213.     add.l    $1c(a3),d0        BSS len
  214.     add.l    #$100,d0        basepage
  215.     move.l    d0,-(sp)
  216.     move.l    a3,-(sp)
  217.     clr.w    -(sp)
  218.     move.w    #$4a,-(sp)
  219.     trap    #1            shrink memory
  220.     lea    12(sp),sp
  221.  
  222.  
  223.  
  224.  
  225. ;=================================================================
  226. ; ----------------  start test for MVG signature ----------------
  227. ;=================================================================
  228.  
  229.         move.b #$30,ernum            start error text number at "0"
  230.  
  231.         move.l $24(a3),a0            parent's basepage adrs
  232.         move.l a0,parent             save temp
  233.         add.l #$80,a0                point A0--> parent's command_line
  234.         move.l (a0)+,a6
  235.         move.l a6,mvg_packet         adrs of packet
  236.         move.l (a0)+,d0
  237.         move.l (a0)+,d1
  238.         cmp.l MVG_SIG,d0             ;0,"MVG"
  239.         bne badbye                   ;MVG is not the caller... no packet
  240.  
  241.         move.b #$31,ernum         ;up the ernum to "1"
  242.         
  243.         cmp.l MVG_VER,d1              ;match version number string "1.30"
  244.         blt badver                    ;MVG is older version than required.
  245.         bgt .2a                       ;additional checking can be made on
  246.                                       ;word following version number in
  247.                                       ;parent's basepage, if necessary.
  248.  
  249.       
  250.       move.b (a0),d0                  ;fetch character (version extension)
  251. ;      clr.w oldver
  252.       cmp.b min_ver,d0                ;1.20 "h" is earliest version usable
  253.       blt badver
  254. ;      bgt .2a
  255. ;      move.w #1,oldver
  256. .2a
  257.       cmp.w MVG_MAX,d1
  258.       bgt badver
  259.  
  260. *****************************************************************************
  261. *************  Set up generic variables and other packet items **************
  262.  
  263.  
  264. read_packet:
  265.   move.l a6,a5
  266.   sub.l #4,a5            ;(Packet - 4) ---> Function dispatcher in MVG
  267.   move.l (a5),mvg_func
  268.   sub.l #4,a5
  269.   move.l (a5),mvg_vars        ;(Packet - 8) ---> Var_List
  270.  
  271.  lea packet,a1
  272.  move.l a6,a0
  273.  move.l #4,d0
  274. .0
  275.  move.l (a0)+,(a1)+        ;copy first 5 items from PACKET
  276.  dbf d0,.0            ;easy way to get adrs of buffers & misc
  277.  
  278.  move.l _wid,a0            ;read width from MVG and store locally
  279.  move.w (a0),wid
  280.  move.l _hgt,a0            ;read height from MVG and store locally
  281.  move.w (a0),hgt
  282.  
  283.  
  284.  jmp Main_Action        ; JUMP TO USER'S CODE
  285.  
  286.  
  287. *************************************************************************
  288. ;========================================================================
  289. ;=============  Some subroutines with labels for local calling ==========
  290.  
  291.  
  292. anykey:
  293.  push.l #ANYKEY
  294.  move.l mvg_func,a6
  295.  jsr (a6)
  296.  addq.l #4,sp
  297.  rts
  298.  
  299. bell
  300.  move.w #7,d0
  301.  
  302. hi_char:
  303.  push.l #HI_CHAR
  304.  move.l mvg_func,a6
  305.  jsr (a6)
  306.  addq.l #4,sp
  307.  rts
  308.  
  309. prin:
  310. hi_string:
  311.  push.l #HI_STRING
  312.  move.l mvg_func,a6
  313.  jsr (a6)
  314.  addq.l #4,sp
  315.  rts
  316.  
  317. ;-------------------------- Copy a string  A0--->A1
  318. copytoz:
  319.  push.l #COPYTOZ
  320.  move.l mvg_func,a6
  321.  jsr (a6)
  322.  addq.l #4,sp
  323.  rts
  324.  
  325.  
  326. ;-------------------------  Poll the mouse position and button status
  327. ;-------------------------- Store the position in local variable 
  328. wherem:
  329.  callmvg WHEREM
  330.  move.l d1,mouse_xy
  331.  rts
  332. mouse_xy
  333. mouse_x dc.w 0
  334. mouse_y dc.w 0
  335.  
  336.  
  337. ;---------------------------------- if you need these routines
  338. ;---------------------------------- then this'll make 'em 
  339. ;---------------------------------- easily accessible as local labels
  340. ;---------------------------------- rather than using "callmvg" each
  341. ;---------------------------------- time you access
  342. addext   callmvgr ADDEXT
  343. appendto callmvgr APPENDTO
  344. bdec2    callmvgr BDEC2
  345. bdec3    callmvgr BDEC3
  346. bdec4    callmvgr BDEC4
  347. phex1    callmvgr PHEX1
  348. hexit    callmvgr HEXIT
  349. hexitl   callmvgr HEXITL 
  350. drawbox  callmvgr MAKEBOX
  351. drawxbox callmvgr MAKEXBOX
  352. askmisc  callmvgr ASKMISC
  353. setsize  callmvgr SETSIZE
  354.  
  355. alerter  callmvgr EALERT
  356. setmousexy callmvgr SETMOUSEXY
  357. atognrm  callmvgr ATOG_NRM
  358. atogxor  callmvgr ATOG_XOR
  359. rectang_q callmvgr RECTANG_Q
  360. setline  callmvgr SET_LINE
  361. makeline callmvgr MAKELINE
  362. toptitle callmvgr TOPTITLE
  363. gdisplay callmvgr GDISPLAY
  364.  
  365.  
  366. ************************************************************************
  367. ************************************************************************
  368. ;--------------------------------------------------------------------
  369. ;Routines for exiting if not run as a module or from a version of MVG
  370. ;that is too early............
  371. ;
  372. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  373. ;
  374. ;          This method of Packet access is only available in
  375. ;          MVG version 1.3...... CHECK FOR THE PROPER VERSION!
  376. ;
  377. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  378. ************************************************************************
  379. ************************************************************************
  380.  
  381.  
  382.  
  383.  
  384.  
  385. badver
  386.  lea ermsg2,a0            ;print error msg
  387.  bsr sysprin
  388.  lea MVG_VER,a0
  389.  bsr sysprin
  390.  bra byex                 ;exit back to... caller (MVG)
  391.  
  392. badbye
  393.  lea ermsg,a0          ;No Packet Provided (MVG not parent of module)
  394.  bsr sysprin
  395. byex
  396.  push.w #7        ;wait for keypress  via GEMDOS
  397.  trap #1
  398.  addq.l #2,sp
  399.  
  400. gbye: 
  401. gbyeoops:
  402.         push.w #2                     ;at this time, MVG does not inquire
  403.         push.w #$4c                   ;for an error return number. This
  404.         trap #1                       ; #2 is arbitrarily selected here.
  405.  
  406. sysprin                               ;print a string using GEMDOS
  407.  push.l a0
  408.  push.w #9
  409.  trap #1
  410.  addq.l #6,sp
  411.  rts
  412.  
  413. good_bye                              ;exit without error code
  414.  push.w #0
  415.  push.w #$4c
  416.  trap #1
  417.  
  418.  
  419.  
  420. ermsg dc.b 27,'Y',32,32,27,'K Err# '
  421. ernum dc.b '0   Cannot Find MVG Packet',7,0
  422.  even
  423. ermsg2 dc.b 27,'Y',32,32,27,'K Requires MVG version # ',0
  424.  even
  425.  
  426.                 
  427. MVG         dc.w 0,0        
  428. MODULE_ID   dc.w 0,0
  429.  
  430. MVG_SIG     dc.b 0,'MVG'
  431. MVG_VER     dc.b '1.30'               ;minimum version MVG to use this module
  432. MVG_SUBVER  dc.b ' ',0                ;a sub version is always 1-byte long.
  433. basepage    dc.l 0 
  434. parent      dc.l 0
  435. mvg_vars    dc.l 0
  436. mvg_func    dc.l 0
  437. mvg_packet  dc.l 0
  438. min_ver     dc.b 0,0                ;SET REQUIRED MINIMUM CHAR HERE
  439. MVG_MAX     dc.b '39',0,0             ;required MAX
  440.  
  441.  
  442. packet:
  443. bgraph    dc.l 0    ;pointer to main image buffer
  444. buflen    dc.l 0    ;length of main image buffer
  445. _wid      dc.l 0    ;pointer to MVG's var: WID
  446. _hgt      dc.l 0    ;pointer to MVG's var: HGT
  447. clipboard dc.l 0    ;pointer to clipboard buffer
  448.  
  449.  
  450. wid dc.w 0        ;local label, loaded with image width (via MVG's WID)
  451. hgt dc.w 0        ;local label, loaded with image height (via MVG's HGT)
  452.  
  453.  
  454. cb_flag   dc.w 0
  455. ;oldver dc.w 0
  456.  
  457.  
  458.  
  459. ***************************************************************************
  460. ***************************************************************************
  461. ***************************************************************************
  462. ***************************************************************************
  463.  
  464. Main_Action
  465.  
  466.  
  467. ; Your code goes here........  exit with P_TERM
  468.  
  469.  
  470. * #############################################################*
  471. * #########   SAMPLE CODE:  COPY VIDEO TO CLIPBOARD  ##########*
  472. * #########                                          ##########*
  473. * #########  Three different samples, all the same   ##########*
  474. * #############################################################*
  475.  
  476.  
  477.  
  478.  
  479. ;----------------------------    standard 68000 syntax
  480. ; move.l #C_V2CB,-(sp)        ;push the function number on the stack
  481. ; movea.l mvg_func,a6        ;get func_dispatcher into address register
  482. ; jsr (a6)            ;JSR indirect via register
  483. ; addq.l #4,(sp)        ;restore stack
  484. ; bra go_byebye            ;exit via p_term
  485. ;
  486. ;----------------------------    same code, using push macro 
  487. ; push.l #C_V2CB
  488. ; move.l mvg_func,a6
  489. ; jsr (a6)
  490. ; addq.l #4,sp
  491. ; bra go_byebye
  492. ;---------------------------    same, again, using "callmvg" macro
  493. ; callmvg #C_V2CB
  494. ; bra go_byebye
  495. ; nop
  496.  
  497. ;go_byebye:
  498. ; push.w #0        ;return error code of zero: no-error
  499. ; push.w #$4c        ;GEMDOS p_term  (exit back to whatever caller)
  500. ; trap #1
  501. ;
  502.  
  503.  
  504.  
  505. * #############################################################*
  506. * #########                                          ##########*
  507. * #########   SAMPLE CODE:  WRITE A GRID to IMAGE    ##########*
  508. * #########                                          ##########*
  509. * #############################################################*
  510.  
  511.  
  512.  
  513.      bsr gdisplay         ;display the current image
  514.      lea first_lert,a0
  515.      moveq #1,d0
  516.      bsr alerter
  517.      
  518.      cmp.w #2,d0
  519.      beq goombye
  520.  
  521.  
  522. grid_rows:
  523.      
  524.      move.l bgraph,a3
  525.       
  526.      clr.l d7
  527.      clr.l d6
  528.      clr.l d5
  529.      
  530.      move.w hgt,d7
  531.      move.w wid,d6
  532.      move.l d6,d5
  533.      lsl.l #4,d5           ;every 16 rows     
  534.  
  535. .0     
  536.      move.b #$ff,d0
  537.      move.l a3,a2
  538.      move.l d6,d1
  539.      subq.w #1,d1
  540. .1     
  541.      move.b d0,(a2)+
  542.      dbf d1,.1
  543.      
  544.      add.l d5,a3
  545.      sub.w #8,d7
  546.      bpl .0
  547.      
  548.  
  549. grid_columns:
  550.      
  551.      move.l bgraph,a3
  552.       
  553.      clr.l d7
  554.      clr.l d6
  555.      clr.l d5
  556.      
  557.      move.w hgt,d7
  558.      move.w wid,d6
  559.      move.l d6,d5
  560.      asr.w #1,d5
  561.  
  562.      subq.w #1,d5
  563.      
  564. .0     
  565.      move.b #$80,d0
  566.      move.l a3,a2
  567.      move.l d7,d1
  568.      subq.w #1,d1
  569. .1     
  570.      move.b (a2),d2
  571.      or.b d0,d2
  572.      move.b d2,(a2)
  573.      add.l d6,a2
  574.      dbf d1,.1
  575.      
  576.      addq.l #2,a3
  577.      dbf d5,.0
  578.      
  579. ;     bsr anykey
  580.      bra goombye
  581.      nop
  582.      
  583.  
  584.  
  585.  
  586. goombye
  587.  push.w #0
  588.  push.w #$4c        P_TERM, this is the way we exit a module
  589.  trap #1                (but you knew that)
  590.  
  591.  
  592. ********************************************************************
  593. ********************************************************************
  594. ********************************************************************
  595.  section data
  596.  even
  597.  
  598.  
  599. ;for sample module
  600.  
  601.  
  602. first_lert dc.b '[0]['
  603.  dc.b ' Draw a Grid on |'
  604.  dc.b '  the current   |'
  605.  dc.b '    Image?      ]'
  606.  dc.b '[Yes|No]'
  607.  even
  608.  
  609.  
  610.  
  611.  
  612. ***************************************************************************
  613. ***************************************************************************
  614. ***************************************************************************
  615. ***************************************************************************
  616.  
  617.  section bss
  618.  even
  619.  
  620.        ds.l 300
  621. ustack ds.l 1
  622.  
  623.  
  624.  end
  625.     
  626.  
  627.